import { RunBack, UpscaleModel } from '@/lib/imageUpscale/types'
import { saveTypes } from '@/lib/imageUpscale/common'
import StorageState from '@/utils/storageState'

export const imagePreviewModes = ['pixelated', 'smooth'] as const
export interface UpscaleModelConfig {
  model: UpscaleModel
  blockSize: number
  backend: RunBack
  saveType: (typeof saveTypes)[number]
  /**
   * 压缩比例 只有在保存为jpg时有效
   */
  saveCompressionRatio: number
  /**
   * 预览模式
   */
  previewMode: (typeof imagePreviewModes)[number]
}
const key = 'imageUpscaleConfigStore'

const defaultValue: UpscaleModelConfig = {
  model: UpscaleModel.waifu_2x_noise,
  blockSize: 64,
  backend: RunBack.cpu,
  saveType: 'png',
  saveCompressionRatio: 1,
  previewMode: 'smooth',
}
export const imageUpscaleConfigStore = new StorageState(key, defaultValue)
